//2.创建路由模块
//导入路由依赖
import {
	createRouter,
	createWebHashHistory,
	createWebHistory
} from 'vue-router'
import Home from './components/Home.vue'

//创建路由实例
const router = createRouter({
	//规定路由模式，hash模式
	history: createWebHashHistory(),
	//定义路由规则
	//语法：一条路由  {path:'/路由地址',component:组件名称}
	routes: [
		//重定向路由，rediect
		{path:'/',redirect:'/home'},
		//嵌套路由，添加children选项,子路由path属性不要有 /
		{
			path: '/home',
			component: Home,
			children: [
				//选取以往的2个组件，为其定义路由规则，并访问成功
				{
					path: 'VOn',
					component: () => import('./components/VOn.vue')
				},
				{
					path: 'VShow',
					component: () => import('./components/VShow.vue')
				},
			]
		},
		//动态路由 
		{
			path: '/about/:moviename',
			component: () => import('./components/About.vue'),
			children:[
				{
					path: ':movieid',
					component: () => import('./components/movieDetails.vue'),
					props:true
				},
			]
		},

	],
	linkActiveClass: 'router-active'

})

//导出路由
export default router